import request from '@/config/axios'

// APP协议配置 VO
export interface AppAgreementVO {
  id: number // 协议ID
  agreementType: number // 协议类型(1:隐私协议,2:用户协议,3:其他协议)
  title: string // 协议标题
  content: string // 协议内容(富文本/HTML)
  version: string // 协议版本号(如:1.0.0)
  isForce: boolean // 是否强制更新(0:否,1:是)
  effectiveDate: Date // 生效时间
  status: number // 状态：0-正常 1-禁用
  platform: string // 适用平台(all:全平台,wechat:微信,alipay:支付宝...)
  creatorId: number // 创建者用户ID
}

// APP协议配置 API
export const AppAgreementApi = {
  // 查询APP协议配置分页
  getAppAgreementPage: async (params: any) => {
    return await request.get({ url: `/system/app-agreement/page`, params })
  },

  // 查询APP协议配置详情
  getAppAgreementById: async (id: number) => {
    return await request.get({ url: `/system/app-agreement/getById?id=` + id })
  },

  // 新增APP协议配置
  createAppAgreement: async (data: AppAgreementVO) => {
    return await request.post({ url: `/system/app-agreement/create`, data })
  },

  // 修改APP协议配置
  updateAppAgreement: async (data: AppAgreementVO) => {
    return await request.post({ url: `/system/app-agreement/update`, data })
  },

  // 修改APP协议配置状态
  updateAppAgreementStatus: async (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return await request.post({ url: `/system/app-agreement/updateStatus`, data: data })
  },

  // 删除APP协议配置
  deleteAppAgreementById: async (id: number) => {
    return await request.get({ url: `/system/app-agreement/delete?id=` + id })
  },

  // 导出APP协议配置 Excel
  exportAppAgreement: async (params) => {
    return await request.download({ url: `/system/app-agreement/export-excel`, params })
  },
}
